package it.tukano.treditor.engine.scene;

import it.tukano.treditor.engine.geom.EulerSet;
import it.tukano.treditor.engine.geom.NTuple3;
import java.io.Serializable;
import java.net.URL;

public class ModelElement implements SceneElement, Serializable {
    
    /* default serial version uid*/
    private static final long serialVersionUID = 0;
    
    private URL modelFileAddress;
    private SceneElement parent;
    private NTuple3 localTranslation = new NTuple3();
    private EulerSet localRotation = new EulerSet();
    private NTuple3 localScale = new NTuple3(1, 1, 1);

    /**
     * Instance initializer
     */
    public ModelElement() {
    }

    public synchronized EulerSet getLocalRotation() {
        return localRotation;
    }

    public synchronized void setLocalRotation(EulerSet localRotation) {
        this.localRotation = localRotation;
    }

    public synchronized NTuple3 getLocalScale() {
        return localScale;
    }

    public synchronized void setLocalScale(NTuple3 localScale) {
        this.localScale = localScale;
    }

    public synchronized NTuple3 getLocalTranslation() {
        return localTranslation;
    }

    public synchronized void setLocalTranslation(NTuple3 localTranslation) {
        this.localTranslation = localTranslation;
    }

    public synchronized URL getModelFileAddress() {
        return modelFileAddress;
    }

    public synchronized void setModelFileAddress(URL modelFileAddress) {
        this.modelFileAddress = modelFileAddress;
    }

    public synchronized SceneElement getParent() {
        return parent;
    }

    public synchronized void setParent(SceneElement parent) {
        this.parent = parent;
    }

    public Type getType() {
        return Type.MODEL;
    }

    @Override
    public String toString() {
        String string = "Undefined Model";
        if(modelFileAddress != null) {
            string = modelFileAddress.getPath();
            final int slashIndex = string.lastIndexOf("/");
            if(slashIndex >= 0) {
                string = string.substring(slashIndex + 1);
            }
        }
        return string;
    }
}
